﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;

/// <summary>
/// Summary description for ValidacionRegex
/// </summary>
public class ValidacionRegex
{
 
    
    public ValidacionRegex()
	{
		
	}

    public bool validarMail(String mail)
    {

        if (mail.Length <= 0 || mail == null || mail.Length > 40)
        {
            return false;
        }
        
        Regex mail_Exp = new Regex ("\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
        return mail_Exp.IsMatch(mail);
    }

    public bool validarTelContacto(String tel)
    {

        if (tel.Length <= 0 || tel == null)
        {
            return false;
        }

        Regex tel_Exp = new Regex("[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]");
        return tel_Exp.IsMatch(tel);
    }

    public bool validarString(String st , int largo)
    {
        if (st.Length <= 2 || st == null || st.Length > largo)
        {
            return false;
        }

        Regex st_Exp = new Regex("[a-zA-Z]+");
        return st_Exp.IsMatch(st);
    
    }

    public bool validarNum(String num)
    {
        if (num == null || num.Length <= 0)
        {
            return false;
        }

        Regex num_Exp = new Regex("[0-9]+");
        return num_Exp.IsMatch(num);
    }
}